<template>
	<form @submit="submitForm" class="addr">
		<view class="addr-card">
			<view class="list flex">
				<view class="label">收货人</view>
				<view class="right">
					<input type="text" placeholder="请填写收货人的姓名" name="username">
				</view>
			</view>
			<view class="list flex">
				<view class="label">联系电话</view>
				<view class="right">
					<input type="text" placeholder="请填写收货人的手机号" name="mobile">
				</view>
			</view>
			<view class="list flex">
				<view class="label">寄送物品</view>
				<view class="right">
					<input type="text" placeholder="请填写寄送物品" name="goods">
				</view>
			</view>
			<view class="list flex">
				<view class="label">收货时间</view>
				<view class="right flex-between" @click="getAddr">
					<view class="addr-text" v-if="address">{{address}}</view>
					<input type="text" disabled placeholder="点击选择收货时间" v-else>
					<view class="iconfont iconyoujiantou1"></view>
				</view>
			</view>
			<view class="list flex">
				<view class="label">收货地址</view>

				<view class="right flex-between" @click="getAddr">
					<view class="addr-text" v-if="address">{{address}}</view>
					<input type="text" disabled placeholder="点击选择收货地址" v-else>
					<view class="iconfont iconyoujiantou1"></view>
				</view>
			</view>
			<view class="list flex">
				<view class="label">详细地址</view>
				<view class="right">
					<input type="text" name="addr_detail" placeholder="详细地址,如11号楼3单元100">
				</view>

			</view>
		</view>
		
		<view class="footer flex-center">
				<button form-type="submit" class="add-btn flex-center">保存</button>
		</view>
	</form>
</template>

<script>
	export default {
		data() {
			return {
				address: "",
			}
		},
		onLoad(options) {
			
		},
		methods: {
			
			// 获取收货地址
			getAddr() {
				uni.chooseLocation({
					success: (res) => {
						this.address = res.address;
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
					}
				});
			},
			submitForm(e){
				console.log(e)
			}
		}
	}
</script>

<style lang="less">
	@main-color:#039702;
	page{
		background: #f2f3f4;
	}
	.addr-card {
		margin-top: 20rpx;
		padding: 0 30rpx;
		background: white;

		.list {
			padding: 20rpx 0;
			border-bottom: 1px solid #eee;

			.label {
				font-size: 30rpx;
				width: 150rpx;
			}

			.right {
				width: 550rpx;
				font-size: 30rpx;
				color: #666;
				.addr-text{
					width: 95%;
				}
				input {
					width: 100%;
					font-size: 30rpx;
					color: #666;
				}
			}
			.left{
				.h3{
					font-size: 28rpx;
					font-weight: bold;
				}
				.p{
					font-size: 20rpx;
					color:#999;
				}
			}
		}
		.del{
			font-size: 30rpx;
			color:red;
		}
	}
	.footer{
		position: fixed;
		bottom:0;
		left: 0;
		width: 100vw;
		height: 80rpx;
		z-index: 1;
		.add-btn{
			width: 680rpx;
			height: 60rpx;
			border-radius: 30rpx;
			background: @main-color;
			font-size: 30rpx;
			color:#fff;
		}
	}
</style>
